package cn.com.dcsgo.controller;

import cn.com.dcsgo.dto.PageDTO;
import cn.com.dcsgo.dto.ProdSearchDTO;
import cn.com.dcsgo.model.ProdEs;
import cn.com.dcsgo.model.Result;
import cn.com.dcsgo.service.SearchService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ES搜索相关接口
 *
 * @author Dcsgo
 * @since 2025/11/3 13:53
 */
@Tag(name = "ES搜索相关接口")
@RestController
public class SearchController {
    @Resource
    private SearchService searchService;

    @GetMapping("prod/prodListByTagId")
    @Operation(summary = "根据活动ID获取商品信息")
    public Result<Page<ProdEs>> getProdListByTagId(PageDTO pageDTO, Long tagId) {
        return Result.success(searchService.getProdListByTagId(pageDTO, tagId));
    }

    @GetMapping("search/searchProdPage")
    @Operation(summary = "搜索商品信息")
    public Result<Page<ProdEs>> searchProd(PageDTO pageDTO, ProdSearchDTO prodSearchDTO) {
        return Result.success(searchService.searchProd(pageDTO, prodSearchDTO));
    }
}
